"""
DBSCAN
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import sklearn.cluster as sc # 聚类模块

data = pd.read_csv('multiple3.txt',header=None,names=['x1','x2'])
print(data)

# plt.scatter(data['x1'],data['x2'],s=50,color='red')
# plt.show()

model = sc.DBSCAN(eps=0.5,min_samples=5)
model.fit(data)

labels = model.labels_
print(labels)

plt.scatter(data['x1'],data['x2'],s=50,c=labels,cmap='brg')
plt.colorbar()

# centers = model.cluster_centers_
# print(centers)
# plt.scatter(centers[:,0],centers[:,1],s=500,c='black',marker='+')
plt.show()
